package com.dgshanger.sanhxiaofeisc.mvp.model

import android.text.TextUtils
import com.blankj.utilcode.util.EncryptUtils
import com.dgshanger.sanhxiaofeisc.common.AppApi
import com.dgshanger.sanhxiaofeisc.mvp.contract.EditPasswordContract
import com.xx.baseutilslibrary.network.rx.RxHelper
import com.xx.baseutilslibrary.network.rx.RxHttpObserver

/**
 * EditPasswordModel
 * 沉迷学习不能自拔
 * Describe：
 * Created by 雷小星🍀 on 2018/4/28 10:59.
 */

class EditPasswordModel : EditPasswordContract.Model {

    override fun modify_pwd(oldPassword: String, newPassword: String, surePassword: String, httpObserver: RxHttpObserver<Any>) {
        AppApi.Api()
                .modify_pwd(if (TextUtils.isEmpty(oldPassword)) null else EncryptUtils.encryptMD5ToString(oldPassword).toLowerCase(),
                        EncryptUtils.encryptMD5ToString(newPassword).toLowerCase(),
                        EncryptUtils.encryptMD5ToString(surePassword).toLowerCase())
                .compose(RxHelper.io_main())
                .subscribe(httpObserver)
    }
}
